<template>
  <div class="warehouse">
    <div class="goodsTop">
      <GRButton :btnText="btnText" class="goodsTopL" />
    </div>
    <div class="warehouseContent">
      <TableList :tableData="tableData" :isCheck="isCheck" :titleList="titleList" :linklist="linklist" :btnState="btnState" :goods_type="type" :url="url" @reshow="dataShow"/>
    </div>

    <router-view />
  </div>
</template>

<script>
  import GRButton from '../../../components/GoodsComponent/GoodsRouterButton.vue'
  import TableList from "../../../components/List.vue";
  import { warehouseList } from '../../../http/apis/goodsApi/warehouse.js'
  import { mapState, mapMutations } from 'vuex'
  export default {
    components: {
      GRButton,
      TableList
    },
    data() {
      return {
        // 表格数据
        tableData: [],
        isCheck: ''
      }
    },
    computed: {
      ...mapState('goodsStore', ['Ftype','btnText','url', 'type', 'linklist', 'titleList', 'selWidth', 'btnState']),
    },
    methods: {
      ...mapMutations('goodsStore', ['Storelist']),
      // 渲染数据转格式
      showDataType(datas) {
        let listArr = datas.filter((item) => {
          return item;
        });
        return listArr;
      },
      // 页面渲染
      dataShow() {
        warehouseList({
          currentPage: this.page,
          pageSize: this.limit,
        })
          .then((res) => {
            console.log('仓库列表渲染成功请求：', res.data.data);
            if (res.data.code == '200') {
              this.tableData = this.showDataType(res.data.data)
            }
          })
          .catch((err) => {
            console.log('请求失败', err)
          });
      },
    },
    created() {
      if (!this.Ftype) {
        this.isCheck = false
      } else {
        this.isCheck = true
      }
      this.Storelist()
      this.dataShow()
    },
  }
</script>

<style>

</style>